﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UtilityHelper.cs" company="Pierhouse ">
//   Copyright 2011 IMS
// </copyright>
// <summary>
//   UtilityHelper
// </summary>
// <author>Thiru </author>
// <history>12/10/2012 </history>
// --------------------------------------------------------------------------------------------------------------------

#region Usings

#endregion Usings

namespace SimpleCodeGen
{
    /// <summary>
    /// UtilityHelper
    /// </summary>
    public class UtilityHelper
    {
        /// <summary>
        /// Gets the settings.
        /// </summary>
        /// <returns></returns>
        public static CustomParameter GetSettings()
        {
            var result = new CustomParameter();
            result.DatabaseServerName = Properties.Settings.Default.DatabaseServerName;
            result.DatabaseSQLAuthenticationMode = Properties.Settings.Default.DatabaseSQLAuthenticationMode;
            result.DatabaseUserName = Properties.Settings.Default.DatabaseUserName;
            result.DatabasePassword = Properties.Settings.Default.DatabasePassword;
            result.DatabaseName = Properties.Settings.Default.DatabaseName;

            result.CompanyName = Properties.Settings.Default.CompanyName;
            result.Copyright = Properties.Settings.Default.Copyright;
            result.DeveloperName = Properties.Settings.Default.DeveloperName;
            result.ClassName = Properties.Settings.Default.ClassName;
            result.OutputFolderPath = Properties.Settings.Default.OutputFolderPath;
            result.GenerateClassAll = Properties.Settings.Default.GenerateClass_All;

            result.GenerateClassBusinessObject = Properties.Settings.Default.GenerateClass_BusinessObject;
            result.GenerateClassBusinessManager = Properties.Settings.Default.GenerateClass_BusinessManager;
            result.GenerateClassBusinessManagerInterface = Properties.Settings.Default.GenerateClass_BusinessManagerInterface;
            result.GenerateClassDataProvider = Properties.Settings.Default.GenerateClass_DataProvider;
            result.GenerateClassDataProviderInterface = Properties.Settings.Default.GenerateClass_DataProviderInterface;
            result.GenerateClassMvcModel = Properties.Settings.Default.GenerateClass_MvcModel;

            result.NamespaceBusinessManager = Properties.Settings.Default.Namespace_BusinessManager;
            result.NamespaceBusinessManagerInterface = Properties.Settings.Default.Namespace_BusinessManagerInterface;
            result.NamespaceBusinessObject = Properties.Settings.Default.Namespace_BusinessObject;
            result.NamespaceDataProvider = Properties.Settings.Default.Namespace_DataProvider;
            result.NamespaceDataProviderInterface = Properties.Settings.Default.Namespace_DataProviderInterface;
            result.NamespaceMvcModel = Properties.Settings.Default.Namespace_MvcModel;

            return result;
        }

        /// <summary>
        /// Saves the settings.
        /// </summary>
        /// <param name="customParameter">The custom parameter.</param>
        /// <returns></returns>
        public static bool SaveSettings(CustomParameter customParameter)
        {
            var result = false;
            if (customParameter != null)
            {
                Properties.Settings.Default.DatabaseServerName = customParameter.DatabaseServerName;
                Properties.Settings.Default.DatabaseSQLAuthenticationMode = customParameter.DatabaseSQLAuthenticationMode;
                Properties.Settings.Default.DatabaseUserName = customParameter.DatabaseUserName;
                Properties.Settings.Default.DatabasePassword = customParameter.DatabasePassword;
                Properties.Settings.Default.DatabaseName = customParameter.DatabaseName;
                Properties.Settings.Default.CompanyName = customParameter.CompanyName;
                Properties.Settings.Default.Copyright = customParameter.Copyright;
                Properties.Settings.Default.DeveloperName = customParameter.DeveloperName;
                Properties.Settings.Default.ClassName = customParameter.ClassName;
                Properties.Settings.Default.OutputFolderPath = customParameter.OutputFolderPath;
                Properties.Settings.Default.GenerateClass_All = customParameter.GenerateClassAll;

                Properties.Settings.Default.GenerateClass_BusinessObject = customParameter.GenerateClassBusinessObject;
                Properties.Settings.Default.GenerateClass_BusinessManager = customParameter.GenerateClassBusinessManager;
                Properties.Settings.Default.GenerateClass_BusinessManagerInterface = customParameter.GenerateClassBusinessManagerInterface;
                Properties.Settings.Default.GenerateClass_DataProvider = customParameter.GenerateClassDataProvider;
                Properties.Settings.Default.GenerateClass_DataProviderInterface = customParameter.GenerateClassDataProviderInterface;
                Properties.Settings.Default.GenerateClass_MvcModel = customParameter.GenerateClassMvcModel;

                Properties.Settings.Default.Namespace_BusinessManager = customParameter.NamespaceBusinessManager;
                Properties.Settings.Default.Namespace_BusinessManagerInterface = customParameter.NamespaceBusinessManagerInterface;
                Properties.Settings.Default.Namespace_BusinessObject = customParameter.NamespaceBusinessObject;
                Properties.Settings.Default.Namespace_DataProvider = customParameter.NamespaceDataProvider;
                Properties.Settings.Default.Namespace_DataProviderInterface = customParameter.NamespaceDataProviderInterface;
                Properties.Settings.Default.Namespace_MvcModel = customParameter.NamespaceMvcModel;

                // save
                Properties.Settings.Default.Save();

                result = true;
            }

            return result;
        }
    }

    /// <summary>
    /// Message type
    /// </summary>
    public enum MessageType
    {
        NotSet = -1,
        Error = 1,
        Success = 2,
        Warning = 3,
        Progress = 4,
    }

    /// <summary>
    /// CodeGenType
    /// </summary>
    public enum CodeGenType
    {
        NotSet = -1,
        BusinessAccessLayer = 1,
        DataAccessLayer = 2,
        MVCLayer = 3
    }

    /// <summary>
    /// ClassType
    /// </summary>
    public enum ClassType
    {
        NotSet = -1,
        CS = 1,
        SQL = 2,
        VB = 3
    }
}